package org.example.springboot.mybatis.controller;

import org.example.springboot.mybatis.po.User;
import org.example.springboot.mybatis.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@RestController
public class UserController {

    @Autowired
    private UserService userService;

    // 查询单个对象
    @GetMapping("/user/{id}")
    public User getUser(@PathVariable String id) {
        User u = userService.getUserById(id);
        return u;
    }

    // 查询用户列表 /users
    @GetMapping("/users/{pageNum}")
    public Map<String, Object> getUser(@PathVariable int pageNum) {
        return userService.getUsers(pageNum);
    }

    // 根据id删除用户  /user/delete/1

    // 创建 /user/create/xxxx
}
